import request from '@/utils/request'

// 查询字典数据列表
export function listData(query) {
  return request({
    url: '/system/dict/data/list',
    method: 'get',
    params: query
  })
}

// 查询字典数据详细
export function getData(dictCode) {
  return request({
    url: '/system/dict/data/' + dictCode,
    method: 'get'
  })
}

// 根据字典类型查询字典数据信息
export function getDicts(dictType) {
  let result = {}
  switch (dictType) {
    case 'sys_user_sex':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"性别男","params":{},"dictCode":1,"dictSort":1,"dictLabel":"男","dictValue":"0","dictType":"sys_user_sex","cssClass":"","listClass":"","isDefault":"Y","status":"0","default":true},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"性别女","params":{},"dictCode":2,"dictSort":2,"dictLabel":"女","dictValue":"1","dictType":"sys_user_sex","cssClass":"","listClass":"","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"性别未知","params":{},"dictCode":3,"dictSort":3,"dictLabel":"未知","dictValue":"2","dictType":"sys_user_sex","cssClass":"","listClass":"","isDefault":"N","status":"0","default":false}]}
      break;
    case 'sys_normal_disable':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"正常状态","params":{},"dictCode":6,"dictSort":1,"dictLabel":"正常","dictValue":"0","dictType":"sys_normal_disable","cssClass":"","listClass":"primary","isDefault":"Y","status":"0","default":true},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"停用状态","params":{},"dictCode":7,"dictSort":2,"dictLabel":"停用","dictValue":"1","dictType":"sys_normal_disable","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false}]}
      break;
    case 'sys_show_hide':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"显示菜单","params":{},"dictCode":4,"dictSort":1,"dictLabel":"显示","dictValue":"0","dictType":"sys_show_hide","cssClass":"","listClass":"primary","isDefault":"Y","status":"0","default":true},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:49","updateBy":null,"updateTime":null,"remark":"隐藏菜单","params":{},"dictCode":5,"dictSort":2,"dictLabel":"隐藏","dictValue":"1","dictType":"sys_show_hide","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false}]}
      break;
    case 'sys_yes_no':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"系统默认是","params":{},"dictCode":12,"dictSort":1,"dictLabel":"是","dictValue":"Y","dictType":"sys_yes_no","cssClass":"","listClass":"primary","isDefault":"Y","status":"0","default":true},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"系统默认否","params":{},"dictCode":13,"dictSort":2,"dictLabel":"否","dictValue":"N","dictType":"sys_yes_no","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false}]}
      break;
    case 'sys_oper_type':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"新增操作","params":{},"dictCode":18,"dictSort":1,"dictLabel":"新增","dictValue":"1","dictType":"sys_oper_type","cssClass":"","listClass":"info","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"修改操作","params":{},"dictCode":19,"dictSort":2,"dictLabel":"修改","dictValue":"2","dictType":"sys_oper_type","cssClass":"","listClass":"info","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"删除操作","params":{},"dictCode":20,"dictSort":3,"dictLabel":"删除","dictValue":"3","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"授权操作","params":{},"dictCode":21,"dictSort":4,"dictLabel":"授权","dictValue":"4","dictType":"sys_oper_type","cssClass":"","listClass":"primary","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"导出操作","params":{},"dictCode":22,"dictSort":5,"dictLabel":"导出","dictValue":"5","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"导入操作","params":{},"dictCode":23,"dictSort":6,"dictLabel":"导入","dictValue":"6","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"强退操作","params":{},"dictCode":24,"dictSort":7,"dictLabel":"强退","dictValue":"7","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"生成操作","params":{},"dictCode":25,"dictSort":8,"dictLabel":"生成代码","dictValue":"8","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"清空操作","params":{},"dictCode":26,"dictSort":9,"dictLabel":"清空数据","dictValue":"9","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false}]}
      break;
    case 'sys_common_status':
      result = {"msg":"操作成功","code":200,"data":[{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"正常状态","params":{},"dictCode":27,"dictSort":1,"dictLabel":"成功","dictValue":"0","dictType":"sys_common_status","cssClass":"","listClass":"primary","isDefault":"N","status":"0","default":false},{"searchValue":null,"createBy":"admin","createTime":"2020-11-20 19:29:50","updateBy":null,"updateTime":null,"remark":"停用状态","params":{},"dictCode":28,"dictSort":2,"dictLabel":"失败","dictValue":"1","dictType":"sys_common_status","cssClass":"","listClass":"danger","isDefault":"N","status":"0","default":false}]}
      break;
    default:
      break;
  }
  return Promise.resolve(result)
  // return request({
  //   url: '/system/dict/data/type/' + dictType,
  //   method: 'get'
  // })
}

// 新增字典数据
export function addData(data) {
  return request({
    url: '/system/dict/data',
    method: 'post',
    data: data
  })
}

// 修改字典数据
export function updateData(data) {
  return request({
    url: '/system/dict/data',
    method: 'put',
    data: data
  })
}

// 删除字典数据
export function delData(dictCode) {
  return request({
    url: '/system/dict/data/' + dictCode,
    method: 'delete'
  })
}

// 导出字典数据
export function exportData(query) {
  return request({
    url: '/system/dict/data/export',
    method: 'get',
    params: query
  })
}
